<template>
  <div v-if="verifyType == 6">
    <a-row style="padding-bottom: 10px;margin-top:12px" v-if="dataXzSource.length">行政审核记录</a-row>
    <a-table bordered :dataSource="dataXzSource" :columns="columns" :scroll="{ y:230}" :pagination="false" v-if="dataXzSource.length">
      <!-- applyStatus  审核状态 1 通过 2 拒绝 3 待审 4 终审通过 5 终审拒绝 -->
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'applyStatus'">
            <a-tag v-if="record.applyStatus == 1" color="green">通过</a-tag>
            <a-tag v-if="record.applyStatus == 2" color="orange">拒绝</a-tag>
            <a-tag v-if="record.applyStatus == 3" color="blue">待审</a-tag>
            <a-tag v-if="record.applyStatus == 4" color="red">终审拒绝</a-tag>
            <a-tag v-if="record.applyStatus == 5" color="green">行政审核通过</a-tag>
            <a-tag v-if="record.applyStatus == 6" color="red">行政审核拒绝</a-tag>
          </template>
      </template>
    </a-table>
  </div>
  <div>
    <a-row style="padding-bottom: 10px" v-if="dataSource.length">审核记录</a-row>
        <!-- 如果已经审核通过了，或者拒绝了不显示 -->
        <!-- <a-card v-if="items.applyStatus !=1 && items.applyStatus !=2"> -->
        <!-- 显示三次的审核意见，结果，时间，审核人 -->
        <!-- <a-card :bordered="false"> -->
        <a-table bordered :dataSource="dataSource" :scroll="{ y:230}" :columns="columnss" :pagination="false" v-if="dataSource.length">
          <template #bodyCell="{ column, record }">
            <template v-if="column.key === 'applyStatus'">
              <a-tag v-if="record.applyStatus == 1" color="green">通过</a-tag>
              <a-tag v-if="record.applyStatus == 2" color="red">拒绝</a-tag>
              <a-tag v-if="record.applyStatus == 3" color="blue">待审</a-tag>
              <a-tag v-if="record.applyStatus == 4" color="red">终审拒绝</a-tag>
              <a-tag v-if="record.applyStatus == 5" color="green">行政审核通过</a-tag>
              <a-tag v-if="record.applyStatus == 6" color="red">行政审核拒绝</a-tag>
            </template>
          </template>
        </a-table>
  </div>
</template>

<script setup>
import { ref, reactive, computed, onMounted, nextTick } from "vue"
import { officeApplyList } from '../MonsterOfficeApply.api'
// 立项审核记录/提交审核记录
import { getRcLog, getLogInfo } from '../MonsterRocProjectSetup.api'
let props = defineProps({
  verifyType: 1, // 类型  1 2 3 立项
  items: '', // 数据集合
  id: ''
})
const ids = ref('')
const dataSource = ref([])
const dataXzSource = ref([])
const columns = [
  {
    title: '项目名称',
    dataIndex: 'projectName',
    key: 'projectName',
  },
  {
      title: '状态',
      dataIndex: 'applyStatus',
      key: 'applyStatus',
      slot: 'applyStatus'
  },
  {
      title: '审核内容',
      dataIndex: 'applyContent',
      key: 'applyContent',
  },
  {
      title: '审核时间',
      dataIndex: 'applyTime',
      key: 'applyTime',
  },
  {
      title: '审核人',
      dataIndex: 'applyUserName',
      key: 'applyUserName',
  },
]

const columnss = ref([
  {
    title: '时间',
    dataIndex: 'applyTime',
    key: 'applyTime',
  },
  {
    title: '结果',
    dataIndex: 'applyStatus',
    key: 'applyStatus',
  },
  {
    title: '审核意见',
    dataIndex: 'applyContent',
    key: 'applyContent',
  },
  {
    title: '审核人',
    dataIndex: 'applyUserName',
    key: 'applyUserName',
  }
])

const childMethod = (obj) => {
  if(obj) {
    ids.value = obj.id
    initData(obj)
  }
}

function initData(obj) {
  if(obj.id) {
    // 立项
    if(props.verifyType == 1 || props.verifyType == 2 || props.verifyType == 3) {
      getRcLog({projectId: obj.id}).then((res) => {
        dataSource.value = res
      })
    }
    // 差旅
    if(props.verifyType == 6) {
      console.log(36)
      officeApplyList({submitId: obj.id}).then((res) => {
        dataXzSource.value = res
      })
    }
    // 提交
    if(props.verifyType == 4 || props.verifyType == 5 || props.verifyType == 6 || props.verifyType == 7) {
      console.log('提交')
      getLogInfo({projectId: obj.projectId,submitId:obj.id}).then((res) => {
        dataSource.value = res
      })
    }
  }
}

defineExpose({ childMethod })
</script>
